package com.example.homemodule.model;

import static com.examination.mlib.constants.AllStringConstants.HomeUrl.AddNew;
import static com.examination.mlib.constants.AllStringConstants.HomeUrl.GetUserAction;
import static com.examination.mlib.constants.AllStringConstants.HomeUrl.QueryRepurchaseList;
import static com.examination.mlib.constants.AllStringConstants.HomeUrl.QueryRepurchaseListNew;
import static com.examination.mlib.constants.AllStringConstants.HomeUrl.queryPatientPendingCount;
import static com.examination.mlib.constants.AllStringConstants.getSecretWord;
import static com.example.homemodule.HomeUrl.getCommodityGroupList;
import static com.example.homemodule.HomeUrl.getHomePageData;

import com.examination.mlib.bean.SecretWordBean;
import com.examination.mlib.bean.BaseBean;
import com.examination.mlib.bean.UserActionEntity;
import com.examination.mlib.constants.AllStringConstants;
import com.example.homemodule.model.bean.AgencyMatterStatiesticsListBean;
import com.example.homemodule.model.bean.HomeCommodityGroupListEntity;
import com.example.homemodule.model.bean.HomepageEntity;
import com.example.homemodule.model.bean.PendingBean;
import com.example.homemodule.model.bean.PrivateDoctorEntity;
import com.example.homemodule.model.bean.ReBuyEntity;
import com.example.homemodule.model.bean.ThumbsUpBean;
import com.example.homemodule.model.bean.live.LiveTabBean;
import com.example.homemodule.HomeUrl;
import com.yilijk.base.base.BaseModel;
import com.yilijk.base.network.RequestParams;
import com.yilijk.base.network.https.HttpCallBack;
import com.yilijk.base.network.https.HttpUtils;

import org.json.JSONArray;

/**
 * Created by SHICHENG
 * <p>
 * Time on
 */
public class HomeModel extends BaseModel {

    public void getCofirmId(String price, String doctorId, String commodityId, String commodityType, HttpCallBack<String> callBack) {
        try {
            RequestParams jsonObject = new RequestParams();
            jsonObject.put("commodityId", commodityId);
            jsonObject.put("commodityType", commodityType);
            jsonObject.put("price", price);
            jsonObject.put("addedQuantity", "1");
            JSONArray objects = new JSONArray();
            objects.put(jsonObject);
            jsonObject = new RequestParams();
            jsonObject.put("doctorId", doctorId);
            jsonObject.put("commodityList", objects);
            objects = new JSONArray();
            objects.put(jsonObject);
            jsonObject = new RequestParams();
            jsonObject.put("totalQuantity", "1");
            jsonObject.put("totalAmount", price);
            jsonObject.put("list", objects);
            HttpUtils.post(AddNew, jsonObject, callBack);
        } catch (Throwable t) {

        }
    }

    //查询药品对应的医生
    public void getQueryDrugToDoctor(int start, String id, String type, HttpCallBack<PrivateDoctorEntity> callBack) {
        RequestParams params = new RequestParams();
        params.put("pageIndex", start + "");
        params.put("pageSize", 10 + "");
        params.put("drug".equals(type) ? "drugId" : "packetId", id);
        HttpUtils.get(AllStringConstants.HomeUrl.CmsDoctorList, params, callBack);

    }

    public void getLiveTab(HttpCallBack<LiveTabBean> callBack) {
        RequestParams jsonObject = new RequestParams();
        jsonObject.put("page_name", "patient_home_app");
        jsonObject.put("api_role", "visitor");

        HttpUtils.get(HomeUrl.index_out, jsonObject, callBack);
    }

    public void getHomeCommodityGroupList(HttpCallBack<HomeCommodityGroupListEntity> callBack) {
        HttpUtils.get(getCommodityGroupList, callBack);
    }

    public void getHomePageBannerData(HttpCallBack<HomepageEntity> callBack) {
        HttpUtils.get(getHomePageData, callBack);
    }

    public void getSecretWord(RequestParams params, HttpCallBack<SecretWordBean> callBack) {
        HttpUtils.get(getSecretWord, params, callBack);
    }

    public void getReBuyDrugDataNew(HttpCallBack<ReBuyEntity> callBack) {
        HttpUtils.post(QueryRepurchaseListNew, callBack);
    }

    public void getReBuyDrugData(HttpCallBack<ReBuyEntity> callBack) {
        HttpUtils.post(QueryRepurchaseList, callBack);
    }

    public void queryPatientPendingCount(HttpCallBack<PendingBean> callBack){

        HttpUtils.get(queryPatientPendingCount, callBack);
    }

    public void getUserAction(HttpCallBack<UserActionEntity> personCenterEntityHttpCallBack) {
        HttpUtils.post(GetUserAction, personCenterEntityHttpCallBack);
    }


    String hidden = "/ihospital-patient/ipatient/myDoctor/hidden";

    public void hiddenDoctor(String doctorId, HttpCallBack<String> httpCallBack) {
        RequestParams params = new RequestParams();
        params.put("doctorId", doctorId);
        HttpUtils.get(hidden, params, httpCallBack);
    }

    String show = "/ihospital-patient/ipatient/myDoctor/show";

    public void showDoctor(long doctorId, HttpCallBack<String> httpCallBack) {
        RequestParams params = new RequestParams();
        params.put("doctorId", doctorId);
        HttpUtils.get(show, params, httpCallBack);
    }

    String jumpUrl = "/vbp-patient/patient/jumpUrl";

    public void getJumpUrl(String passportId, HttpCallBack<String> httpCallBack) {
        RequestParams params = new RequestParams();
        params.put("passportId", passportId);
        HttpUtils.get(jumpUrl, params, httpCallBack);
    }

    public void thumbsUp(int id, int thumbs, HttpCallBack<ThumbsUpBean> callBack) {
        RequestParams params = new RequestParams();
        params.put("healthNumberArticleId", id);
        params.put("count", thumbs);
        HttpUtils.get(HomeUrl.thumbsUp, params, callBack);
    }

    public void thumbsdown(int id, HttpCallBack<ThumbsUpBean> callBack) {
        RequestParams params = new RequestParams();
        params.put("healthNumberArticleId", id);
        HttpUtils.get(HomeUrl.thumbsdown, params, callBack);
    }

    public void getAgencyMatterStatisticsList(HttpCallBack<AgencyMatterStatiesticsListBean> callBack){
        HttpUtils.get(HomeUrl.getAgencyMatterStatisticsList,callBack);

    }

    public void notifyOpenCharge(String doctorId,HttpCallBack<BaseBean> callBack) {
        RequestParams params = new RequestParams();
        params.put("doctorId", doctorId);
        HttpUtils.get(HomeUrl.notifyOpenCharge, params, callBack);
    }
}
